Visual Studio Code 能够自动检测grunt文件,无需配置就可以使用快捷键执行grunt编译任务:
VS Code can autodetect tasks from within Gulp, Grunt and Jake files. This adds their tasks to the task list without requiring additional configuration (unless you need to use a problem matcher, more on that in a moment).
但是如果grunt文件不在VS Code管理的根目录,那么用快捷键执行就会报错。 解决方法是在tasks.json中配置命令的cwd参数为grunt文件所在的文件夹。 其中${cwd}是VS Code预定的变量,代表当前的工作目录。
{
// See https://go.microsoft.com/fwlink/?LinkId=733558
// for the documentation about the tasks.json format
"version": "0.1.0",
"command": "grunt",
"isShellCommand": true,
"showOutput": "always",
"options": {
"cwd": "${cwd}/subfolder"
}
}